# 202401 Crypto
from Crypto.Util.number import *
import random
# from secrets import flag
flag = b"flag{wakaka}"


assert b'flag' in flag
p = getPrime(192)
q = getPrime(192)
n = p * q
e = random.getrandbits(32)
a = random.getrandbits(64)
b = random.getrandbits(64)
# 椭圆的标准方程: x ** 2 / a ** 2 + y ** 2 / b ** 2 == 1
# Elliptic Curve Cryptography: 椭圆曲线加密
E = EllipticCurve(Zmod(p), [a, b])
P = E.random_point()
Q = e * P
m = bytes_to_long(flag)
c = pow(m, e, n)
print(f'n = {n}')
print(f'P = {P.xy()}')
print(f'Q = {Q.xy()}')
print(f'c = {c}')
# n = 24579139606784371097119450777505497559902788044390859486207103747911130645847199807655291463605216259630814564993059
# P = (2441276631279438325107649016771386750283631250456176007047, 518977588578348104829006572552789464653487828502604088614)
# Q = (145209878471534003613216346594463133860677999091779831326, 2012072911059587487946252884280697891223335402503553158653)
# c = 14133235712331301067661853998574340918787633413015450541376377985972174127101361772980044023936510086832676457922180
